1. Technical Field
The present invention relates to a method and apparatus for data processing in general, and in particular to a method and apparatus for assisting garbage collection within a data-processing system. Still more particularly, the present invention relates to a method and apparatus for assisting a garbage collection process within a Java virtual machine.
2. Description of the Prior Art
Like most object-oriented applications, a Java application typically allocates new objects to a region of a system memory within a data-processing system commonly referred to as a "heap." During execution, the Java application relies on a garbage collection process to reclaim space within the heap that is no longer utilized by previously allocated objects. The garbage collection process is typically invoked whenever the Java application attempts to create a new object but there is insufficient free space available within the heap to satisfy such object allocation.
In an uniprocessor Java virtual machine, a "synchronous" garbage collection process is typically employed for performing the task of heap space reclamation. Generally, the synchronous garbage collection process begins its operations by temporarily stopping all Java application(s) within the Java virtual machine. Next, the synchronous garbage collection process traverses a Java stack and the heap in order to search for all active objects and their "children." These active objects and their "children" are then marked accordingly. Afterwards, the heap is searched again for a second time to reclaim (or free) any space previously utilized by unmarked (or dead) objects. At times, the synchronous garbage collection process may even compact all live objects within the heap to eliminate fragmentation. Finally, the Java application(s) is/are restarted again.
Conservatively speaking, a typical synchronous garbage collection process may delay Java application(s) for periods of up to several hundred milliseconds and may even attribute up to 5 to 25% of the total runtime of these Java application(s). While existing software implementations of concurrent garbage collection processes may help in reducing the length of the delay time, they cannot reduce the actual time spent on garbage collection; and in fact, they may even increase the total runtime of the Java application(s).
In addition, garbage collection processes are intrinsically complicated because most objects allocated by Java applications have non-uniform size and variable life-times such that multiple garbage collection algorithms are typically required to tackle various heap space reclamation problems. As a result, garbage collection processes are constantly consuming a significant percentage of the total runtime of Java applications. Thus, it would be desirable to provide an improved method and apparatus for assisting garbage collection processes within a Java virtual machine.